package com.ruoyi.monitor.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.monitor.domain.MonitorApprovalRecord;
import com.ruoyi.monitor.service.IMonitorApprovalRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 审批记录Controller
 *  
 * @author cl
 * @date 2025-04-16
 */
@RestController
@RequestMapping("/monitor/record")
public class MonitorApprovalRecordController extends BaseController
{
    @Autowired
    private IMonitorApprovalRecordService monitorApprovalRecordService;

    /**
     * 查询审批记录列表
     */
    @PreAuthorize("@ss.hasPermi('monitor:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(MonitorApprovalRecord monitorApprovalRecord)
    {
        startPage();
        List<MonitorApprovalRecord> list = monitorApprovalRecordService.selectMonitorApprovalRecordList(monitorApprovalRecord);
        return getDataTable(list);
    }

    /**
     * 导出审批记录列表
     */
    @PreAuthorize("@ss.hasPermi('monitor:record:export')")
    @Log(title = "审批记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MonitorApprovalRecord monitorApprovalRecord)
    {
        List<MonitorApprovalRecord> list = monitorApprovalRecordService.selectMonitorApprovalRecordList(monitorApprovalRecord);
        ExcelUtil<MonitorApprovalRecord> util = new ExcelUtil<MonitorApprovalRecord>(MonitorApprovalRecord.class);
        util.exportExcel(response, list, "审批记录数据");
    }

    /**
     * 获取审批记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('monitor:record:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Integer recordId)
    {
        return success(monitorApprovalRecordService.selectMonitorApprovalRecordByRecordId(recordId));
    }

    /**
     * 新增审批记录
     */
    @PreAuthorize("@ss.hasPermi('monitor:record:add')")
    @Log(title = "审批记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MonitorApprovalRecord monitorApprovalRecord)
    {
        return toAjax(monitorApprovalRecordService.insertMonitorApprovalRecord(monitorApprovalRecord));
    }

    /**
     * 修改审批记录
     */
    @PreAuthorize("@ss.hasPermi('monitor:record:edit')")
    @Log(title = "审批记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MonitorApprovalRecord monitorApprovalRecord)
    {
        return toAjax(monitorApprovalRecordService.updateMonitorApprovalRecord(monitorApprovalRecord));
    }

    /**
     * 删除审批记录
     */
    @PreAuthorize("@ss.hasPermi('monitor:record:remove')")
    @Log(title = "审批记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Integer[] recordIds)
    {
        return toAjax(monitorApprovalRecordService.deleteMonitorApprovalRecordByRecordIds(recordIds));
    }
}
